<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><link rel="stylesheet" type="text/css" href="style.css" /><script type="text/javascript" src="highlight.js"></script></head><body><pre><span class="hs-pragma">{-# LANGUAGE BangPatterns #-}</span><span>
</span><span id="line-2"></span><span class="hs-pragma">{-# LANGUAGE CPP #-}</span><span>
</span><span id="line-3"></span><span class="hs-pragma">{-# LANGUAGE MagicHash #-}</span><span>
</span><span id="line-4"></span><span class="hs-keyword">module</span><span> </span><span class="hs-identifier">Data.Text.Internal.ByteStringCompat</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="Data.Text.Internal.ByteStringCompat.html#mkBS"><span class="hs-identifier">mkBS</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="Data.Text.Internal.ByteStringCompat.html#withBS"><span class="hs-identifier">withBS</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-5"></span><span>
</span><span id="line-6"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../bytestring/src/Data.ByteString.Internal.html#"><span class="hs-identifier">Data.ByteString.Internal</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../bytestring/src/Data.ByteString.Internal.html#ByteString"><span class="hs-identifier">ByteString</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-glyph">..</span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-7"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/Data.Word.html#"><span class="hs-identifier">Data.Word</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.Word.html#Word8"><span class="hs-identifier">Word8</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-8"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/Foreign.ForeignPtr.html#"><span class="hs-identifier">Foreign.ForeignPtr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.ForeignPtr.html#ForeignPtr"><span class="hs-identifier">ForeignPtr</span></a></span><span class="hs-special">)</span><span class="hs-cpp">

#if !MIN_VERSION_bytestring(0,11,0)
</span><span class="hs-cpp">#if MIN_VERSION_base(4,10,0)
</span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/GHC.ForeignPtr.html#"><span class="hs-identifier">GHC.ForeignPtr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.ForeignPtr.html#plusForeignPtr"><span class="hs-identifier">plusForeignPtr</span></a></span><span class="hs-special">)</span><span class="hs-cpp">
#else
</span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">GHC.ForeignPtr</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">ForeignPtr</span><span class="hs-special">(</span><span class="hs-identifier">ForeignPtr</span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-15"></span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">GHC.Types</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">Int</span><span> </span><span class="hs-special">(</span><span class="hs-glyph">..</span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-16"></span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">GHC.Prim</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">plusAddr#</span><span class="hs-special">)</span><span class="hs-cpp">
#endif
</span><span class="hs-cpp">#endif
</span><span>
</span><span id="line-20"></span><span class="annot"><a href="Data.Text.Internal.ByteStringCompat.html#mkBS"><span class="hs-identifier hs-type">mkBS</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.ForeignPtr.html#ForeignPtr"><span class="hs-identifier hs-type">ForeignPtr</span></a></span><span> </span><span class="annot"><a href="../../base/src/GHC.Word.html#Word8"><span class="hs-identifier hs-type">Word8</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Int"><span class="hs-identifier hs-type">Int</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../bytestring/src/Data.ByteString.Internal.html#ByteString"><span class="hs-identifier hs-type">ByteString</span></a></span><span class="hs-cpp">
#if MIN_VERSION_bytestring(0,11,0)
</span><span class="hs-identifier">mkBS</span><span> </span><span class="hs-identifier">dfp</span><span> </span><span class="hs-identifier">n</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">BS</span><span> </span><span class="hs-identifier">dfp</span><span> </span><span class="hs-identifier">n</span><span class="hs-cpp">
#else
</span><span id="mkBS"><span class="annot"><span class="annottext">mkBS :: ForeignPtr Word8 -&gt; Int -&gt; ByteString
</span><a href="Data.Text.Internal.ByteStringCompat.html#mkBS"><span class="hs-identifier hs-var hs-var">mkBS</span></a></span></span><span> </span><span id="local-6989586621679104262"><span class="annot"><span class="annottext">ForeignPtr Word8
</span><a href="#local-6989586621679104262"><span class="hs-identifier hs-var">dfp</span></a></span></span><span> </span><span id="local-6989586621679104261"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679104261"><span class="hs-identifier hs-var">n</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">ForeignPtr Word8 -&gt; Int -&gt; Int -&gt; ByteString
</span><a href="../../bytestring/src/Data.ByteString.Internal.html#PS"><span class="hs-identifier hs-var">PS</span></a></span><span> </span><span class="annot"><span class="annottext">ForeignPtr Word8
</span><a href="#local-6989586621679104262"><span class="hs-identifier hs-var">dfp</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">0</span></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679104261"><span class="hs-identifier hs-var">n</span></a></span><span class="hs-cpp">
#endif
</span><span class="hs-pragma">{-# INLINE</span><span> </span><span class="annot"><a href="Data.Text.Internal.ByteStringCompat.html#mkBS"><span class="hs-pragma hs-type">mkBS</span></a></span><span> </span><span class="hs-pragma">#-}</span><span>
</span><span id="line-27"></span><span>
</span><span id="line-28"></span><span id="local-6989586621679104269"><span class="annot"><a href="Data.Text.Internal.ByteStringCompat.html#withBS"><span class="hs-identifier hs-type">withBS</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../bytestring/src/Data.ByteString.Internal.html#ByteString"><span class="hs-identifier hs-type">ByteString</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.ForeignPtr.html#ForeignPtr"><span class="hs-identifier hs-type">ForeignPtr</span></a></span><span> </span><span class="annot"><a href="../../base/src/GHC.Word.html#Word8"><span class="hs-identifier hs-type">Word8</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Int"><span class="hs-identifier hs-type">Int</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621679104269"><span class="hs-identifier hs-type">r</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621679104269"><span class="hs-identifier hs-type">r</span></a></span></span><span class="hs-cpp">
#if MIN_VERSION_bytestring(0,11,0)
</span><span class="hs-identifier">withBS</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">BS</span><span> </span><span class="hs-glyph">!</span><span class="hs-identifier">sfp</span><span> </span><span class="hs-glyph">!</span><span class="hs-identifier">slen</span><span class="hs-special">)</span><span>       </span><span class="hs-identifier">kont</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">kont</span><span> </span><span class="hs-identifier">sfp</span><span> </span><span class="hs-identifier">slen</span><span class="hs-cpp">
#else
</span><span id="withBS"><span class="annot"><span class="annottext">withBS :: forall r. ByteString -&gt; (ForeignPtr Word8 -&gt; Int -&gt; r) -&gt; r
</span><a href="Data.Text.Internal.ByteStringCompat.html#withBS"><span class="hs-identifier hs-var hs-var">withBS</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../bytestring/src/Data.ByteString.Internal.html#PS"><span class="hs-identifier hs-type">PS</span></a></span><span> </span><span class="hs-glyph">!</span><span id="local-6989586621679104259"><span class="annot"><span class="annottext">ForeignPtr Word8
</span><a href="#local-6989586621679104259"><span class="hs-identifier hs-var">sfp</span></a></span></span><span> </span><span class="hs-glyph">!</span><span id="local-6989586621679104258"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679104258"><span class="hs-identifier hs-var">soff</span></a></span></span><span> </span><span class="hs-glyph">!</span><span id="local-6989586621679104257"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679104257"><span class="hs-identifier hs-var">slen</span></a></span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621679104256"><span class="annot"><span class="annottext">ForeignPtr Word8 -&gt; Int -&gt; r
</span><a href="#local-6989586621679104256"><span class="hs-identifier hs-var">kont</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">ForeignPtr Word8 -&gt; Int -&gt; r
</span><a href="#local-6989586621679104256"><span class="hs-identifier hs-var">kont</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">ForeignPtr Word8 -&gt; Int -&gt; ForeignPtr Word8
forall a b. ForeignPtr a -&gt; Int -&gt; ForeignPtr b
</span><a href="../../base/src/GHC.ForeignPtr.html#plusForeignPtr"><span class="hs-identifier hs-var">plusForeignPtr</span></a></span><span> </span><span class="annot"><span class="annottext">ForeignPtr Word8
</span><a href="#local-6989586621679104259"><span class="hs-identifier hs-var">sfp</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679104258"><span class="hs-identifier hs-var">soff</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679104257"><span class="hs-identifier hs-var">slen</span></a></span><span class="hs-cpp">
#endif
</span><span class="hs-pragma">{-# INLINE</span><span> </span><span class="annot"><a href="Data.Text.Internal.ByteStringCompat.html#withBS"><span class="hs-pragma hs-type">withBS</span></a></span><span> </span><span class="hs-pragma">#-}</span><span class="hs-cpp">

#if !MIN_VERSION_bytestring(0,11,0)
</span><span class="hs-cpp">#if !MIN_VERSION_base(4,10,0)
</span><span class="hs-comment">-- |Advances the given address by the given offset in bytes.</span><span>
</span><span id="line-39"></span><span class="hs-comment">--</span><span>
</span><span id="line-40"></span><span class="hs-comment">-- The new 'ForeignPtr' shares the finalizer of the original,</span><span>
</span><span id="line-41"></span><span class="hs-comment">-- equivalent from a finalization standpoint to just creating another</span><span>
</span><span id="line-42"></span><span class="hs-comment">-- reference to the original. That is, the finalizer will not be</span><span>
</span><span id="line-43"></span><span class="hs-comment">-- called before the new 'ForeignPtr' is unreachable, nor will it be</span><span>
</span><span id="line-44"></span><span class="hs-comment">-- called an additional time due to this call, and the finalizer will</span><span>
</span><span id="line-45"></span><span class="hs-comment">-- be called with the same address that it would have had this call</span><span>
</span><span id="line-46"></span><span class="hs-comment">-- not happened, *not* the new address.</span><span>
</span><span id="line-47"></span><span class="hs-identifier">plusForeignPtr</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">ForeignPtr</span><span> </span><span class="hs-identifier">a</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">Int</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">ForeignPtr</span><span> </span><span class="hs-identifier">b</span><span>
</span><span id="line-48"></span><span class="hs-identifier">plusForeignPtr</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">ForeignPtr</span><span> </span><span class="hs-identifier">addr</span><span> </span><span class="hs-identifier">guts</span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">I#</span><span> </span><span class="hs-identifier">offset</span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">ForeignPtr</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">plusAddr#</span><span> </span><span class="hs-identifier">addr</span><span> </span><span class="hs-identifier">offset</span><span class="hs-special">)</span><span> </span><span class="hs-identifier">guts</span><span>
</span><span id="line-49"></span><span class="hs-pragma">{-# INLINE</span><span> </span><span class="hs-pragma">[</span><span class="hs-pragma">0</span><span class="hs-pragma">]</span><span> </span><span class="hs-pragma">plusForeignPtr</span><span> </span><span class="hs-pragma">#-}</span><span>
</span><span id="line-50"></span><span class="hs-pragma">{-# RULES</span><span>
</span><span id="line-51"></span><span class="hs-pragma">&quot;ByteString plusForeignPtr/0&quot;</span><span> </span><span class="hs-pragma">forall</span><span> </span><span class="hs-pragma">fp</span><span> </span><span class="hs-pragma">.</span><span>
</span><span id="line-52"></span><span>   </span><span class="hs-pragma">plusForeignPtr</span><span> </span><span class="hs-pragma">fp</span><span> </span><span class="hs-pragma">0</span><span> </span><span class="hs-pragma">=</span><span> </span><span class="hs-pragma">fp</span><span>
</span><span id="line-53"></span><span> </span><span class="hs-pragma">#-}</span><span class="hs-cpp">
#endif
</span><span class="hs-cpp">#endif
</span><span>
</span><span id="line-57"></span></pre></body></html>